#ifndef _KC_UNSAFERECEIVER_H__KC_
#define _KC_UNSAFERECEIVER_H__KC_

#include <string>
#include "Receiver.h"
#include "../../comm/tcp/TCPCommon.h"
#include "../../mime/data/RawMessage.h"
#include "../../mime/data/Address.h"

namespace kc_sf
{
	/** Receiver, ktory rozmawia z klientem na niezabezpieczonym kanale */
	class UnsafeReceiver : public Receiver
	{
		public:

			explicit UnsafeReceiver( const Connection &connection );
			CommRequestHandler *getInstance( const Connection &connection ) const;
			void operator()();

		protected:

			RawMessage r_msg;

			CommResult processHelo( const Command & cmd );
			CommResult processEhlo( const Command & cmd );
			CommResult processBaseHelo( const Command &cmd, Reply &reply );
			CommResult processAuthPlain( const Command & cmd );
			CommResult processAuthLogin( const Command & cmd );
			CommResult processStartTLS();
			CommResult processMailFrom( const Command & cmd );
			CommResult processRcpt( const Command & cmd );
			CommResult processData();
			CommResult processBdat( const Command & cmd );
			CommResult processNoop();
			CommResult processQuit();
			CommResult processRset();
			CommResult processUnimplemented( const Command & cmd );
			CommResult processUndefined( const Command & cmd );

			bool isEndOfMsg(const std::string & text) const;

			bool isAllowedInState(int cmd_type);
			bool stripSourceRoute(const std::string &route_mailbox, Address &mailbox) const;
	};
}

#endif // _KC_UNSAFERECEIVER_H__KC_
